#!/bin/bash
set -eu

TESTDIR=$(readlink -f $(dirname $0))
. $TESTDIR/framework

setupenvironment

buildpackage 'conflicting-package-distupgrade'
buildpackage 'conflicting-package-one'
buildpackage 'conflicting-package-two'
buildpackage 'missing-dependency'
buildpackage 'simple-package-new'
buildpackage 'simple-package-noarch'
buildpackage 'simple-package'
buildpackage 'simple-package-update-conflict'
buildpackage 'simple-package-update' # overwrites the previous built package

generaterepository_and_switch_sources "$TMPWORKINGDIRECTORY/usr/src/RPM/RPMS"

testsuccess aptget update

testregexmatch 'simple-package-2-alt1@[0-9]+' aptcache depends 'simple-package'

testregexmatch 'missing-dependency-1-alt1@[0-9]+
  Depends: <no-such-package>' aptcache depends 'missing-dependency'

testregexmatch 'conflicting-package-one-2-alt1@[0-9]+
  Conflicts: conflicting-package-two
  Conflicts: simple-package
    simple-package-new-3-alt1@[0-9]+' aptcache depends 'conflicting-package-one'

testregexmatch 'missing-dependency-1-alt1@[0-9]+
  Depends: <no-such-package>' aptcache depends 'missing-dependency'

testregexmatch '<no-such-package>' aptcache depends 'no-such-package'

testregexmatch 'W: Unable to locate package definitely-no-such-package' aptcache depends 'definitely-no-such-package'
